import { Plugin } from 'obsidian';
import SearchOutlineModal from './searchOutlineModal';
import HeadingTree from './headingTree';
import Util from './util';

export default class FloatOutlinePlugin extends Plugin {

	async onload() {
		Util.init(this);

		this.addCommand({
			id: 'open-search-outline-modal',
			name: 'Open Search Outline',
			checkCallback: (checking: boolean) => {
				let have = Util.haveActiveFile();
				if (have) {
					if (!checking) {
						new SearchOutlineModal(this, new HeadingTree(this.app)).open();
					}
					return true;
				}
				return false;
			}
		});
	}

}
